repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git]
/
11428 - Cubes
/
b.2.cpp
blob
a584ca6d02bf37871311022e72fca7cc77d27701
1
#include<iostream>
2
#include<math.h>
3
using namespace
std
;
4
5
int
cubo
(
int
x
){
6
int
i
=
1
;
7
while
(
i
*
i
*
i
<=
x
){
8
++
i
;
9
}
10
--
i
;
11
// cout << i << endl;
12
if
(
i
*
i
*
i
==
x
){
13
return
i
;
14
}
else
{
15
return
INT_MAX
;
16
}
17
}
18
19
int
main
(){
20
int
n
;
21
while
(
cin
>>
n
&&
n
){
22
int
y
=
1
;
23
bool
encontre
=
false
;
24
while
(
true
){
25
int
r
=
cubo
(
n
+ (
y
*
y
*
y
));
26
// cout << "r es: " << r << " y es: " << y << endl;
27
if
(
r
!=
INT_MAX
){
28
cout
<<
r
<<
" "
<<
y
<<
endl
;
29
encontre
=
true
;
30
break
;
31
}
32
++
y
;
33
if
((
y
+
1
)*(
y
+
1
)*(
y
+
1
) -
y
*
y
*
y
>
n
)
break
;
34
}
35
if
(!
encontre
){
36
cout
<<
"No solution
\n
"
;
37
continue
;
38
}
39
}
40
}